package ch03.game.sb.spaceblaster;

import android.content.Context;
import android.graphics.Paint;
import android.util.AttributeSet;

public class SpaceBlasterGame extends ArcadeGame
{
	// Game name
	public static final String NAME = "SpaceBlaster";
	// Refresh rate (ms)
	private static final long UPDATE_DELAY = 40;
	private Context mContext;
	// For text
	private Paint mTextPaint = new Paint();
	// For Bitmaps
	private Paint mBitmapPaint = new Paint();
	private Paint mLaserBarPaint = new Paint();
	private Paint mShieldBarPaint = new Paint();
	private Paint mShieldPaint = new Paint();
	/**
	* Constructor
	*
	* @param context
	*/
	public SpaceBlasterGame(Context context) {
		super(context);
		mContext = context;
		super.setUpdatePeriod(UPDATE_DELAY);
	}
	public SpaceBlasterGame(Context context, AttributeSet attrs) {
		super(context, attrs);
		mContext = context;
		super.setUpdatePeriod(UPDATE_DELAY);
	}
	@Override
	protected void updatePhysics() {
		// TODO Auto-generated method stub
		
	}
	@Override
	protected void initialize() {
		int n;
		// Screen size
		int width = getWidth();
		int height = getHeight();
		// Text Paints
		mTextPaint.setARGB(255, 255, 255, 255);
		mShieldPaint.setARGB(125, 0, 255, 255);
		// Laser Bar Energy
		mLaserBarPaint.setARGB(255, 0, 255, 96);
		mLaserBarPaint.setStyle(Paint.Style.FILL);
		// Shield Bar Energy
		mShieldBarPaint.setARGB(255, 0, 255, 255);
		mShieldBarPaint.setStyle(Paint.Style.FILL);
//		ship = getImage(R.drawable.sb_ship);
//		bullet = getImage(R.drawable.sb_bullet);
//		fire = new Bitmap[fireframe];
//		// Load fire image sprites
//		int[] ids = new int[] { R.drawable.sb_fire0, R.drawable.sb_fire1 };
//		for (n = 0; n < fireframe; n++) {
//		fire[n] = getImage(ids[n]);
//		}
//		// Load meteor explosion sequence sprites
//		ids = new int[] { R.drawable.sb_boom0, R.drawable.sb_boom1,
//		R.drawable.sb_boom2, R.drawable.sb_boom3,
//		R.drawable.sb_boom4 };
//		boom = new Bitmap[bframes + 1];
//		for (n = 0; n <= bframes; n++) {
//		boom[n] = getImage(ids[n]);
//		}
//		// ...
//		// Meteor initialize
//		meteor = getImage(R.drawable.sb_meteor);
//		// ...
//		// Load Audio clips
//		try {
//		blast = getAudioClip(R.raw.sb_blast);
//		crash = getAudioClip(R.raw.sb_collisn);
//		kill = getAudioClip(R.raw.sb_mdestr);
//		} catch (Exception e) {
//		Tools.MessageBox(mContext, "Audio Error: " + e.toString());
//		}
//		initStars();
		// ...
		
	}
	@Override
	protected boolean gameOver() {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	protected long getScore() {
		// TODO Auto-generated method stub
		return 0;
	}
	// Code removed for simplicity
	// See chapter source
	// ...
	
	/**
	* create the star field in the background
	*/
	public void initStars() {
//		starsX = new int[numStars];
//		starsY = new int[numStars];
//		starsC = new Paint[numStars];
//		for (int i = 0; i < numStars; i++) {
//			starsX[i] = (int) ((Math.random() * xSize - 1) + 1);
//			starsY[i] = (int) ((Math.random() * ySize - 1) + 1);
//			starsC[i] = newColor();
//		}
	}
	public Paint newColor() {
//		int r = Math.random() * 255;
//		int g = Math.random() * 255;
//		int b = Math.random() * 255;
		Paint p = new Paint();
//		p.setARGB(255, r, g, b);
		return p;
	}
}
